package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.BasisClass;
import com.ruoyi.system.service.IBasisClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 岗位信息Controller
 *
 * @author ruoyi
 * @date 2025-03-03
 */
@RestController
@RequestMapping("/system/class")
public class BasisClassController extends BaseController
{
    @Autowired
    private IBasisClassService basisClassService;

    /**
     * 查询班级信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:class:list')")
    @GetMapping("/list")
    public TableDataInfo list(BasisClass basisClass)
    {
        startPage();
        List<BasisClass> list = basisClassService.selectBasisClassList(basisClass);
        return getDataTable(list);
    }

    /**
     * 导出岗位信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:class:export')")
    @Log(title = "班级信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BasisClass basisClass)
    {
        List<BasisClass> list = basisClassService.selectBasisClassList(basisClass);
        ExcelUtil<BasisClass> util = new ExcelUtil<BasisClass>(BasisClass.class);
        return util.exportExcel(list, "班级信息数据");
    }

    /**
     * 获取岗位信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:class:query')")
    @GetMapping(value = "/{classId}")
    public AjaxResult getInfo(@PathVariable("classId") Long classId)
    {
        return AjaxResult.success(basisClassService.selectBasisClassById(classId));
    }

    /**
     * 新增岗位信息
     */
    @PreAuthorize("@ss.hasPermi('system:class:add')")
    @Log(title = "班级信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasisClass basisClass)
    {
        return toAjax(basisClassService.insertBasisClass(basisClass));
    }

    /**
     * 修改岗位信息
     */
    @PreAuthorize("@ss.hasPermi('system:class:edit')")
    @Log(title = "班级信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasisClass basisClass)
    {
        return toAjax(basisClassService.updateBasisClass(basisClass));
    }

    /**
     * 删除岗位信息
     */
    @PreAuthorize("@ss.hasPermi('system:class:remove')")
    @Log(title = "班级信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{classIds}")
    public AjaxResult remove(@PathVariable Long[] classIds)
    {
        return toAjax(basisClassService.deleteBasisClassByIds(classIds));
    }
}
